/**
 * 
 */
package messaage;

/**
 * @author Olga
 * 
 */
public class AddedFriendMsg extends Message {

	protected String friendName;

	/**
	 * 
	 */
	public AddedFriendMsg(String username, String friendName) {
		super.username = username;
		this.friendName = friendName;
	}
	
	public AddedFriendMsg(String msg){
		parse(msg);
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see messaage.Message#toString()
	 */
	@Override
	public String toString() {
		return "FriendAdded\n" + "username:" + this.username + "\nfriendName:"
				+ this.friendName + "\n\0";
	}

	/**
	 * @return the friendName
	 */
	public String getFriendName() {
		return friendName;
	}

    private void parse(String msg) {
        String[] lInfo = msg.split("\n");
        String[] tInfo1 = lInfo[1].split(":");
        this.username = tInfo1[1];
        String[] tInfo2 = lInfo[2].split(":");
        this.friendName = tInfo2[1];
    }

}
